package com.spring.gop.proj.aspect;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect @Component
public class LogAspect {
 private static Logger logger = Logger.getLogger(LogAspect.class);

 @Before("execution(* *..UserService.*(..))") 
 public void logBefore(JoinPoint jp) {  
  logger.warn(jp.toShortString()+" 시작.");
 }
 
 @AfterReturning("execution(* *..UserService.*(..))") 
 public void logAfter(JoinPoint jp) {  
  logger.warn(jp.toShortString()+" 끝.");
 }
 
 @AfterThrowing(pointcut="execution(* *..UserService.*(..))",throwing="e") 
 public void logError(JoinPoint jp,Throwable e) {  
  logger.error(jp.toShortString()+" 에러.");
  logger.error(e);
 }
}